#ifndef OP_BE_GROUP_BY_OUTPUT_H
#define OP_BE_GROUP_BY_OUTPUT_H

#include <cstddef>
#include "proto/internal.pb.h"
#include "Op.h"

class OpBEGroupBy;

// TODO destruktor i zwalnianie pamięci

class OpOutput: public Op {
  private:
  	OpBEGroupBy* group_by ;
	std::vector<char*> package; // package
	std::vector<char*> next; // point in package currently writing to
	std::size_t rowSize;
  	
	std::vector<char> flags; // flag whether package is the last one (is sent with end of transmission message)
  	char* last_row ;
  	
  	std::vector<char*> *rows;
  	
  	int rowsPerPackage ;
  	
  public:
	OpOutput(const internal::OutputOperation& operation) ;

  	int doit() ;
  
  private:
  	void send(int nr) ;
} ;

#endif
